package com.chinawlx.wlxteacher.base;

import android.util.Log;

/**
 * Observer的父类
 * Created by cyc on 16-2-17.
 */
public class BaseWebObserver<T> implements rx.Observer<T> {
    static private final String TAG = "BaseWebObserver";

    private WebData_CallBack<T> mCallBack;

    @Override
    public void onCompleted() {
    }

    @Override
    public void onError(Throwable e) {
        if (mCallBack != null) {
            mCallBack.netCallbackError(e);
        }

    }

    @Override
    public void onNext(T t) {
        Log.d(TAG, "onNext in");
        if (mCallBack != null) {
            mCallBack.netCallbackOK(t);
        }
    }

    public void setWebDataCallBack(WebData_CallBack<T> mCallBack) {
        this.mCallBack = mCallBack;
    }

    public interface WebData_CallBack<T> {
        /**
         * 数据回来时调用
         */
        void netCallbackOK(T t);

        void netCallbackError(Throwable e);
    }


}
